package com.linewell.aop;

import com.linewell.annotation.EncrptionAop;
import com.linewell.pojo.Book;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * @Title: license-app216
 * @description:
 * @author: hyuhuang@linewell.com
 * @since:2019/5/27
 */
@Aspect
@Component
public class BookEncrptionAop {
    /**
     * <p>Discription:[后置通知，扫描com.linewell包及此包下的所有带有SystemLogAop注解的方法]</p>
     * @param joinPoint 前置参数
     * @param encrptionAop 自定义注解
     * @author:[全冉]
     */
    @After(("execution(* com.linewell.daoImpl.*.*(..)) && @annotation(encrptionAop)"))
    public void doAfterAdvice(JoinPoint joinPoint, EncrptionAop encrptionAop) {
        System.out.println("方法后");
    }

    @Before(("execution(* com.linewell.daoImpl.*.*(..)) && @annotation(encrptionAop)"))
    public void before(JoinPoint joinPoint,EncrptionAop encrptionAop){
        //获取目标方法的参数信息
        Object[] obj = joinPoint.getArgs();
        Book books = (Book) obj[0];
        books.setReader("124124124");
    }
}
